<?php

class IndexController extends Zend_Controller_Action
{
    protected $_picModel;
    protected $_introductionModel;
    protected $_announcementModel;
    protected $_teacherModel;
    protected $_studentModel;
    
    public function init()
    {
        $this->_picModel = new Eleven_Model_Picture();
        
        $this->_introductionModel = new Eleven_Model_Introduction();
        
        $this->_announcementModel = new Eleven_Model_Announcement();
        
        $this->_teacherModel = new Eleven_Model_Teacher();
        
        $this->_studentModel = new Eleven_Model_Student();
        
        $this->_userModel = new Eleven_Model_User();
        
		$this->view->userForm = $this->getUserForm();
    }

    public function indexAction()
    {
        $this->view->introduction = $this->_introductionModel->getIntroduction();
        $this->view->indexPics = $this->_picModel->getIndexPics();
        $this->view->announcements = $this->_announcementModel->getIndexAnnouns();
        
		$this->view->currentContents = $this->_studentModel->getCurrentContents($this->_getParam('topicId',null));
		
		
		
    }
    
    public function studentlistAction()
    {
		$this->view->currentContents = $this->_studentModel->getCurrentContents($this->_getParam('topicId',null));
    }
    
    public function teacherlistAction()
    {
		$this->view->currentContents = $this->_teacherModel->getCurrentContents($this->_getParam('topicId',null));
    }

    public function getUserForm( )
	{
		$urlHelper = $this->_helper->getHelper('url');

        $this->_forms['user'] = $this->_teacherModel->getForm('userLogin');
        $this->_forms['user']->setAction($urlHelper->url(array(
            'controller' => 'customer',
            'action' => 'authenticate'
            ),
            'default'
        ));
        
        $this->_forms['user']->setMethod('post');
        
        return $this->_forms['user'];
	}
}

